import http from "@/api";

/**
 * @name //发卡中心管理
 */
// 获取人员列表
export const getEmployeeList = (params = {}) => {
  return http.post(`/employee/query`, params, { noLoading: true });
};

// 获取有效期内人员列表
export const getValidEmployeeList = (params = {}) => {
  return http.post(`/employee/card-valid/query`, params, { noLoading: true });
};

// 新增人员
export const addEmployee = (params = {}) => {
  return http.post(`employee/create`, params, { noLoading: true });
};

// 编辑人员
export const editEmployee = (params = {}) => {
  return http.post(`employee/update`, params, { noLoading: true });
};

// 删除人员
export const delEmployee = (params: { id: string }) => {
  return http.post(`employee/delete`, params, { noLoading: true });
};

// 挂失
export const lockCard = (params: { id: string }) => {
  return http.post(`employee/card/lock`, params, { noLoading: true });
};

// 解挂
export const unlockCard = (params: { id: string }) => {
  return http.post(`employee/card/unlock`, params, { noLoading: true });
};

// 重置密码
export const resetPsd = (params: { id: string }) => {
  return http.post(`employee/resetPWD`, params, { noLoading: true });
};

// 修改密码
export const updatePsd = (params: { id: string; stringParam1: string; captcha: string }) => {
  return http.post(`employee/modifyPWD`, params, { noLoading: true });
};

// 读取卡片
export const readCard = (params: { stringParam1: string }) => {
  return http.post(`employee/card/read`, params);
};

// 修改卡片有效期
export const updateValid = (params = {}) => {
  return http.post(`rule/card-valid/update/selected`, params, { noLoading: true });
};

// 修改所有卡片有效期
export const updateValidAll = (params = {}) => {
  return http.post(`rule/card-valid/update/all`, params, { noLoading: true });
};

// 导入人员
export const uploadExcle = (params: { excel: File }) => {
  return http.post(`employee/import`, params, {
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
};

// 下载照片
export const downloadPhoto = (params: { empid: string }) => {
  return http.get(`employee/photo/download`, params, {}, { noTips: true });
};

// 导入人员
export const uploadPhoto = (params: { empid: string; photo: File }) => {
  return http.post(`employee/photo/upload`, params, {
    headers: {
      "Content-Type": "multipart/form-data"
    }
  });
};
